﻿using System.Collections.Generic;
using AgileBoard.Domain;

namespace AgileBoard.Dtos.Mappers
{
    public class StatusDTOMapper : BaseDTOMapper
    {
        public static StatusDTO MapToDTO(Status model)
        {
            var dto = new StatusDTO();
            IList<TaskDTO> taskDTO = new List<TaskDTO>();

            dto.ID = model.StatusID;
            //dto.IterationID = model.IterationID;            
            dto.Name = model.Name;
            dto.CreateTime = model.CreateTime;
            dto.Creator = model.Creator;

            //load tasks
            foreach (Task task in model.Tasks)
            {
                taskDTO.Add(TaskDTOMapper.MapToDTO(task));
            }
            dto.items = taskDTO;

            return dto;
        }

        public static Status MapFromDTO(StatusDTO dto)
        {
            var status = new Status();
            status.StatusID = dto.ID;
            //Status.IterationID = dto.IterationID;            
            status.Name = dto.Name;
            status.CreateTime = dto.CreateTime;
            status.Creator = dto.Creator;

            return status;
        }
    }
}